import 'package:syn_4s/core/model/user_tag_model.dart';

import 'user_model.dart';

class LoginModel {
  String? token;
  String? refreshToken;
  UserModel? userInfo;
  List<UserTagModel>? tags;

  LoginModel.fromJson(Map<String, dynamic> json) {
    userInfo =
        json['userInfo'] != null ? UserModel.fromJson(json['userInfo']) : null;
    token = json['token'];
    refreshToken = json['refreshToken'];
    if (json['tags'] != null) {
      tags = <UserTagModel>[];
      json['tags'].forEach((v) {
        tags!.add(UserTagModel.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = Map<String, dynamic>();
    if (userInfo != null) {
      data['userInfo'] = userInfo!.toJson();
    }
    data['token'] = token;
    data['refreshToken'] = refreshToken;
    if (this.tags != null) {
      data['tags'] = this.tags!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}
